<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('商品信息列表')" />
</head>
<body class="gray-bg">
     <div class="container-div">
        <div class="row">
            <div class="col-sm-12 search-collapse">
                <form id="formId">
                    <div class="select-list">
                        <ul>
                            <li>
                                <label>名称：</label>
                                <input type="text" name="name"/>
                            </li>
                            <li>
                                <label>种类：</label>
                                <select name="type" th:with="type=${@dict.getType('commodity_type')}">
                                    <option value="">所有</option>
                                    <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                                </select>
                            </li>
                            <li>
                                <label>价格：</label>
                                <input type="text" name="price"/>
                            </li>
                            <li>
                                <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                                <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                            </li>
                        </ul>
                    </div>
                </form>
            </div>

            <div class="btn-group-sm" id="toolbar" role="group">
                <a class="btn btn-success" onclick="$.operate.add()" shiro:hasPermission="system:commodity:add">
                    <i class="fa fa-plus"></i> 添加
                </a>
                <a class="btn btn-primary single disabled" onclick="$.operate.edit()" shiro:hasPermission="system:commodity:edit">
                    <i class="fa fa-edit"></i> 修改
                </a>
                <a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()" shiro:hasPermission="system:commodity:remove">
                    <i class="fa fa-remove"></i> 删除
                </a>
                <a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="system:commodity:export">
                    <i class="fa fa-download"></i> 导出
                </a>
            </div>
            <div class="col-sm-12 select-table table-striped">
                <table id="bootstrap-table"></table>
            </div>
        </div>
    </div>
    <th:block th:include="include :: footer" />
    <script th:inline="javascript">
        var editFlag = [[${@permission.hasPermi('system:commodity:edit')}]];
        var removeFlag = [[${@permission.hasPermi('system:commodity:remove')}]];
        var typeDatas = [[${@dict.getType('commodity_type')}]];
        var prefix = ctx + "system/commodity";

        $(function() {
            var options = {
                url: prefix + "/list",
                createUrl: prefix + "/add",
                updateUrl: prefix + "/edit/{id}",
                removeUrl: prefix + "/remove",
                exportUrl: prefix + "/export",
                modalName: "商品信息",
                columns: [{
                    checkbox: true
                },
                {
                    field: 'id',
                    title: '商品编号',
                },
                {
                    field: 'picture',
                    title: '图片',
                    formatter: function(value, row, index) {
				    	if((row.name) == "红茶"){
				    		return $.table.imageView('https://img1.baidu.com/it/u=2794693753,1423129852&fm=253&fmt=auto&app=138&f=JPEG?w=500&h=500');
				    	} else if((row.name) == "绿茶"){
				    		return $.table.imageView('https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fimg.alicdn.com%2Fi2%2F678415212%2FO1CN01P6qUvN1oN8sS92eP6_%21%21678415212.jpg&refer=http%3A%2F%2Fimg.alicdn.com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=auto?sec=1706788421&t=d833e5937b9a9b092ad304e3998964ee');
				    	} else if((row.name) == "桔茶"){
				    		return $.table.imageView('https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fimg.alicdn.com%2Fi2%2F114435239%2FO1CN01ZTzVi41oZVZpk1GrW_%21%21114435239.jpg&refer=http%3A%2F%2Fimg.alicdn.com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=auto?sec=1706788475&t=e10e06c1403638b3c4f99040cff08aab');
				    	} else if((row.name) == "香蕉茶"){
				    		return $.table.imageView('https://img2.baidu.com/it/u=1161359733,2331956802&fm=253&fmt=auto&app=138&f=JPEG?w=500&h=500');
				    	} else if((row.name) == "椰子茶"){
				    		return $.table.imageView('https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fcbu01.alicdn.com%2Fimg%2Fibank%2FO1CN01XZpff31CvzoMXimfe_%21%212214662920144-0-cib.jpg_270x270xzq60.jpg&refer=http%3A%2F%2Fcbu01.alicdn.com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=auto?sec=1706788607&t=f51b06c933d2d82b2c74b4e7d182b873');
				    	} else if((row.name) == "柠檬茶"){
				    		return $.table.imageView('https://img12.360buyimg.com/imgzone/jfs/t1/210805/13/6433/60270/617388ccE324d9a8f/65e02af0664ad585.jpg');
				    	} else if((row.name) == "三明治"){
				    		return $.table.imageView('https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fsafe-img.xhscdn.com%2Fbw1%2F0c43058e-17b4-49b2-9b09-f7f4ecd1a738%3FimageView2%2F2%2Fw%2F1080%2Fformat%2Fjpg&refer=http%3A%2F%2Fsafe-img.xhscdn.com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=auto?sec=1706788666&t=855e011ad5b8309c5328c55631a584e0');
				    	}
				    }
                },
                {
                    field: 'name',
                    title: '名称'
                },
                {
                    field: 'type',
                    title: '种类',
                    formatter: function(value, row, index) {
                       return $.table.selectDictLabel(typeDatas, value);
                    }
                },
                {
                    field: 'price',
                    title: '价格'
                },
                {
                    field: 'cost',
                    title: '成本'
                },
                {
                    field: 'description',
                    title: '描述'
                },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function(value, row, index) {
                        var actions = [];
                        actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.id + '\')"><i class="fa fa-edit"></i>编辑</a> ');
                        actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.id + '\')"><i class="fa fa-remove"></i>删除</a>');
                        return actions.join('');
                    }
                }]
            };
            $.table.init(options);
        });


    </script>
</body>
</html>